package com.decent.manager.system.dao;

import com.decent.manager.system.dao.provider.SystemOrderDaoProvider;
import com.decent.manager.system.dto.SystemOrderDTO;
import com.decent.manager.system.vo.SystemOrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author: decent Gjh
 * @date: 2022/11/02/9:39
 * @description:
 */
@Mapper
public interface SystemOrderDao {
    /**
     * 根据条件查找订单
     * @param order 查询条件
     * @return 订单列表
     */
    @SelectProvider(type = SystemOrderDaoProvider.class, method = "list")
    List<SystemOrderVO> selectOrderList(@Param("order") SystemOrderDTO order);

    /**
     * 关闭指定时间之前创建的未支付的订单
     * @param dateTime 创建时间
     * @return 影响行数
     */
    @Update("update common_order set order_state = 'CLOSED' where create_datetime < #{dateTime} and order_state = 'UNPAID' ")
    int closeOvertimeOrders(@Param("dateTime") LocalDateTime dateTime);
}
